<?php

namespace Common\Model;

use Think\Model;

class QuestionTagModel extends Model
{
    protected $_validate = array(//array('title','require','问题标题必须填写！',1),
    );


    protected $_auto = array(//array('issolve','0'),
    );

    /**
     * 通过问题ID获取TAG
     *
     * @param string $qid
     * @return array
     */
    public function get_tag_qid($qid = '')
    {
        $map['qid'] = intval($qid);
        $tag = $this->where($map)->select();
        foreach ($tag as $v) {
            $v['tagurl'] = RU('tag/view', array('t' => $v['tagid']));
            $tags[] = $v;
        }
        return $tags;
    }

    /**
     * 通过TAGID获取最新的问题标签
     *
     * @param string $tagid
     * @param string $limit
     * @return mixed
     */
    public function get_tag_tagid($tagid = '', $limit = '')
    {
        $map['tagid'] = intval($tagid);
        $tag = $this->where($map)->order('id DESC')->limit($limit)->select();
        return $tag;
    }

}